<?php
    $pathToRoot = "../";

    // ----------------------------------------------------------------
    require_once $pathToRoot . "Controller/LoginController.php";
    require_once $pathToRoot . "Controller/LoginActionController.php";
    require_once $pathToRoot . "Controller/RegisterController.php";

    require_once $pathToRoot . "View/LoginView.php";
    require_once $pathToRoot . "View/LoginActionView.php";
    require_once $pathToRoot . "View/RegisterView.php";

    require_once $pathToRoot . "Model/LoginHandler.php";
    require_once $pathToRoot . "Model/LoginActionHandler.php";
    require_once $pathToRoot . "Model/RegisterHandler.php";

    require_once $pathToRoot . "Common/Database.php";
    require_once $pathToRoot . "Common/DBConfig.php";    
    require_once $pathToRoot . "Common/User.php";
    require_once $pathToRoot . "Common/Validate.php";
    // ----------------------------------------------------------------

    // Startar en ny session om en inte redan är satt.
    if (isset($_SESSION) == false) {
        session_start();  
    }

    $title = "Mina Sidor";

    // Skapar objekt.
    $dbConfig = new DBConfig();
    $database = new Database($dbConfig);
    $validate =  new Validate();
    
    $loginHandler = new LoginHandler($database);
    $registerHandler = new RegisterHandler($database, $validate);
    
    $loginView = new LoginView();
    $registerView = new RegisterView();
    $loginActionView = new LoginActionView();

    $loginController = new loginController();
    $registerController = new RegisterController($validate);
    $loginActionController = new LoginActionController($loginHandler, $loginActionView);

    // Kontrollerar vem som är inloggad så vi kan få ut rätt menu och content till användaren.
    $login = $loginController->DoLogInControll($loginHandler, $loginView);
    $content = $loginActionController->DoLoginActionControll();
    $database->CloseConnection();
?>
<?php include($pathToRoot . "Common/Head.php");?>        
<body>    
    <div id="wrapper">    
        <?php include($pathToRoot . "Common/Menu.php");?>            
        <div id="container">
            <div id="content">
               <?php echo $content; ?>          
            </div>           
        </div>
        <?php include($pathToRoot . "Common/Footer.php");?>